共计 1326 个字符,预计需要花费 4 分钟才能阅读完成。
GitHub地址:百度分享代码 下载压缩包;
解压可得:
注意! 将static文件夹整个丢到Spring Boot工程的static目录下面(如下图)
前端页面js代码部分:
src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='
修改为:
src='/static/api/js/share.js?v=89860593.js?cdnversion='
完整版可参考如下:
<div class="bdsharebuttonbox">
<a href="#" class="bds_more" data-cmd="more"></a>
<a href="#" class="bds_fbook" data-cmd="fbook" title="分享到Facebook"></a>
<a href="#" class="bds_twi" data-cmd="twi" title="分享到Twitter"></a>
<a href="#" class="bds_linkedin" data-cmd="linkedin" title="分享到linkedin"></a>
<a href="#" class="bds_qzone" data-cmd="qzone" title="分享到QQ空间"></a>
<a href="#" class="bds_tsina" data-cmd="tsina" title="分享到新浪微博"></a>
<a href="#" class="bds_douban" data-cmd="douban" title="分享到豆瓣网"></a>
<a href="#" class="bds_weixin" data-cmd="weixin" title="分享到微信"></a>
<a href="#" class="bds_evernotecn" data-cmd="evernotecn" title="分享到印象笔记"></a>
</div>
<script>window._bd_share_config = {
"common": {
"bdSnsKey": {},
"bdText": (获取到文章内容传递过去),
"bdMini": "2",
"bdMiniList": false,
"bdPic": (获取到文章图片传递过去),
"bdStyle": "1",
"bdSize": "24"
},
"share": {},
"image": {
"viewList": ["fbook", "twi", "linkedin", "qzone", "tsina", "douban", "weixin", "evernotecn"],
"viewText": "分享到:",
"viewSize": "16"
}
};
with (document) 0[(getElementsByTagName('head')[0] || body).appendChild(createElement('script')).src = '/static/api/js/share.js?v=89860593.js?cdnversion=' + ~(-new Date() / 36e5)];
</script>
正文完
站点开启https,百度分享不能用,怎么办?